<template>
	<van-tabbar fixed route>
		<van-tabbar-item v-for="(item, i) of tabbarItems" :key="i" 
			:icon="item.icon" :to="item.routePath" 
		>{{ item.title }}</van-tabbar-item>
	</van-tabbar>
</template>

<script>
export default {
	data() {
		return {
			selectedTab: 0, //选中的TabBar
			tabbarItems: [
				{
					title: '首页',
					routePath: '/',
					icon: 'home-o'
				},
				{
					title: '商品',
					routePath: '/product/list',
					icon: 'gift-o'
				},
				{
					title: '购物车',
					routePath: '/shopcart',
					icon: 'shopping-cart-o'
				},
				{
					title: '我的',
					routePath: '/user',
					icon: 'user-o'
				}
			]
		};
	},
	
	methods: {
		onChange(index) {
			if(this.$route.name !== this.tabbarItems[index].routeName)
			{
				this.$router.push({
					name: this.tabbarItems[index].routeName
				});
			}
			
		}
	}
};
</script>
